#!/usr/bin/env python
#coding=utf8
#LittleDispatcher
#author:linluxiang@gmail.com
#version:0.1
import re
from django.core.urlresolvers import RegexURLPattern, RegexURLResolver

_pattern_list=[] #url缓存。。。 

def expose(pattern=None):
    def decorator(f):
        global _pattern_list
        _pattern_list.append(RegexURLPattern(pattern,f)) #增加Pattern
    return decorator

#以下函数根据指定path返回相应处理函数。。
def getCallback(s):
    global _pattern_list
    for i in _pattern_list:
        if i and isinstance(i,RegexURLPattern):    
            callback=i.resolve(s)
            if callback:
                return callback
    if callback:
        return callback
 
